<?php

/**
 * Permissions base class.
 *
 * @author    Mon Zafra <monzee at gmail>
 * @copyright (c)2009 Mon Zafra
 * @license   http://monzee.wordpress.com/license New BSD
 * @version   $Id: Permission.php 38 2009-02-18 17:12:39Z monzee $
 */
abstract class Admin_Doctrine_Base_Permission extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('permissions');
        $this->hasColumn('resource_id', 'string', 128, array('type' => 'string', 'primary' => true, 'length' => '128'));
        $this->hasColumn('role_id', 'string', 64, array('type' => 'string', 'primary' => true, 'length' => '64'));
        $this->hasColumn('privilege', 'string', 64, array('primary' => true));
        $this->hasColumn('allowed', 'boolean');

        $this->index('role', array('fields' => array('role_id')));
    }

    public function setUp()
    {
        $this->hasOne('Admin_Doctrine_Role as Role', array('local' => 'role_id',
                                                           'foreign' => 'id'));
    }
}